<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>RTCPeerConnection</title>
</head>

<body>


  <script>

    let peer = new RTCPeerConnection({
      iceServers: [
        {}
      ]
    })
    // 媒体协商方法


    // peer.createOffer({}) // 创建 offer 发送给对方
    // peer.createAnswer() // 响应请求
    // peer.setLocalDescription() // 保存本地offer
    // peer.setRemoteDescription()  // 将远程offer 保存到本地


    // 事件
    // peer.addStream( )  // 
    // peer.createOffer({
    //   offerToReceiveAudio: 1,
    //   offerToReceiveVidio: 1
    // })

    // 基本流程
    // 发起通话  peer.createOffer   peer.addStream()   peer.setLocalDescription

    // 收到通话   peer.createOffer   peer.addStream()   peer.createAnswer(offer)  peet.setRemoteDescription(offer)  peer.setLocalDescription(offer)

    peer.onicecandidate = function () {  // 监听 candidate

    }
    peer.addIceCandidate() // 添加  candidate

    peer.onaddstream = () => { } // 收到用户 stream

  </script>

</body>

</html>